package com.zoe.wan.android.example.repository.data

import android.os.Parcel
import android.os.Parcelable


/**
 * 体系数据
 */
class KnowledgeListData : ArrayList<KnowledgeListDataItem?>()



data class KnowledgeListDataItem(
    val articleList: List<Any?>?,
    val author: String?,
    val children: List<Children?>?,
    val courseId: Int?,
    val cover: String?,
    val desc: String?,
    val id: Int?,
    val lisense: String?,
    val lisenseLink: String?,
    val name: String?,
    val order: Int?,
    val parentChapterId: Int?,
    val type: Int?,
    val userControlSetTop: Boolean?,
    val visible: Int?
) : Parcelable {
    constructor(parcel: Parcel) : this(
        parcel.readList(mutableListOf<Any?>(), Any::class.java.classLoader) as List<Any?>?,
        parcel.readString(),
        parcel.createTypedArrayList(Children),
        parcel.readValue(Int::class.java.classLoader) as? Int,
        parcel.readString(),
        parcel.readString(),
        parcel.readValue(Int::class.java.classLoader) as? Int,
        parcel.readString(),
        parcel.readString(),
        parcel.readString(),
        parcel.readValue(Int::class.java.classLoader) as? Int,
        parcel.readValue(Int::class.java.classLoader) as? Int,
        parcel.readValue(Int::class.java.classLoader) as? Int,
        parcel.readValue(Boolean::class.java.classLoader) as? Boolean,
        parcel.readValue(Int::class.java.classLoader) as? Int
    ) {
    }

    override fun describeContents(): Int {
        return 0
    }

    override fun writeToParcel(parcel: Parcel, flags: Int) {
        parcel.writeList(articleList)
        parcel.writeString(author)
        parcel.writeTypedList(children)
        parcel.writeValue(courseId)
        parcel.writeString(cover)
        parcel.writeString(desc)
        parcel.writeValue(id)
        parcel.writeString(lisense)
        parcel.writeString(lisenseLink)
        parcel.writeString(name)
        parcel.writeValue(order)
        parcel.writeValue(parentChapterId)
        parcel.writeValue(type)
        parcel.writeValue(userControlSetTop)
        parcel.writeValue(visible)
    }


    companion object CREATOR : Parcelable.Creator<KnowledgeListDataItem> {
        override fun createFromParcel(parcel: Parcel): KnowledgeListDataItem {
            return KnowledgeListDataItem(parcel)
        }

        override fun newArray(size: Int): Array<KnowledgeListDataItem?> {
            return arrayOfNulls(size)
        }
    }
}


data class Children(
    val articleList: List<Article?>?,
    val author: String?,
    val children: List<Any?>?,
    val courseId: Int?,
    val cover: String?,
    val desc: String?,
    val id: Int?,
    val lisense: String?,
    val lisenseLink: String?,
    val name: String?,
    val order: Int?,
    val parentChapterId: Int?,
    val type: Int?,
    val userControlSetTop: Boolean?,
    val visible: Int?
) : Parcelable {
    constructor(parcel: Parcel) : this(
        parcel.createTypedArrayList(Article.CREATOR),
        parcel.readString(),
        parcel.readList(mutableListOf<Any?>(), Any::class.java.classLoader) as List<Any?>?,
        parcel.readValue(Int::class.java.classLoader) as? Int,
        parcel.readString(),
        parcel.readString(),
        parcel.readValue(Int::class.java.classLoader) as? Int,
        parcel.readString(),
        parcel.readString(),
        parcel.readString(),
        parcel.readValue(Int::class.java.classLoader) as? Int,
        parcel.readValue(Int::class.java.classLoader) as? Int,
        parcel.readValue(Int::class.java.classLoader) as? Int,
        parcel.readValue(Boolean::class.java.classLoader) as? Boolean,
        parcel.readValue(Int::class.java.classLoader) as? Int
    )

    override fun writeToParcel(parcel: Parcel, flags: Int) {
        parcel.writeTypedList(articleList)
        parcel.writeString(author)
        parcel.writeList(children)
        parcel.writeValue(courseId)
        parcel.writeString(cover)
        parcel.writeString(desc)
        parcel.writeValue(id)
        parcel.writeString(lisense)
        parcel.writeString(lisenseLink)
        parcel.writeString(name)
        parcel.writeValue(order)
        parcel.writeValue(parentChapterId)
        parcel.writeValue(type)
        parcel.writeValue(userControlSetTop)
        parcel.writeValue(visible)
    }


    override fun describeContents(): Int = 0

    companion object CREATOR : Parcelable.Creator<Children> {
        override fun createFromParcel(parcel: Parcel): Children = Children(parcel)
        override fun newArray(size: Int): Array<Children?> = arrayOfNulls(size)
    }
}


data class Article(
    val adminAdd: Boolean?,
    val apkLink: String?,
    val audit: Int?,
    val author: String?,
    val canEdit: Boolean?,
    val chapterId: Int?,
    val chapterName: String?,
    val collect: Boolean?,
    val courseId: Int?,
    val desc: String?,
    val descMd: String?,
    val envelopePic: String?,
    val fresh: Boolean?,
    val host: String?,
    val id: Int?,
    val isAdminAdd: Boolean?,
    val link: String?,
    val niceDate: String?,
    val niceShareDate: String?,
    val origin: String?,
    val prefix: String?,
    val projectLink: String?,
    val publishTime: Long?,
    val realSuperChapterId: Int?,
    val selfVisible: Int?,
    val shareDate: Long?,
    val shareUser: String?,
    val superChapterId: Int?,
    val superChapterName: String?,
    val tags: List<Any?>?,
    val title: String?,
    val type: Int?,
    val userId: Int?,
    val visible: Int?,
    val zan: Int?
):Parcelable {
    constructor(parcel: Parcel) : this(
        parcel.readValue(Boolean::class.java.classLoader) as? Boolean,
        parcel.readString(),
        parcel.readValue(Int::class.java.classLoader) as? Int,
        parcel.readString(),
        parcel.readValue(Boolean::class.java.classLoader) as? Boolean,
        parcel.readValue(Int::class.java.classLoader) as? Int,
        parcel.readString(),
        parcel.readValue(Boolean::class.java.classLoader) as? Boolean,
        parcel.readValue(Int::class.java.classLoader) as? Int,
        parcel.readString(),
        parcel.readString(),
        parcel.readString(),
        parcel.readValue(Boolean::class.java.classLoader) as? Boolean,
        parcel.readString(),
        parcel.readValue(Int::class.java.classLoader) as? Int,
        parcel.readValue(Boolean::class.java.classLoader) as? Boolean,
        parcel.readString(),
        parcel.readString(),
        parcel.readString(),
        parcel.readString(),
        parcel.readString(),
        parcel.readString(),
        parcel.readValue(Long::class.java.classLoader) as? Long,
        parcel.readValue(Int::class.java.classLoader) as? Int,
        parcel.readValue(Int::class.java.classLoader) as? Int,
        parcel.readValue(Long::class.java.classLoader) as? Long,
        parcel.readString(),
        parcel.readValue(Int::class.java.classLoader) as? Int,
        parcel.readString(),
        parcel.readList(mutableListOf<Any?>(), Any::class.java.classLoader) as List<Any?>?,
        parcel.readString(),
        parcel.readValue(Int::class.java.classLoader) as? Int,
        parcel.readValue(Int::class.java.classLoader) as? Int,
        parcel.readValue(Int::class.java.classLoader) as? Int,
        parcel.readValue(Int::class.java.classLoader) as? Int
    ) {
    }

    override fun writeToParcel(parcel: Parcel, flags: Int) {
        parcel.writeValue(adminAdd)
        parcel.writeString(apkLink)
        parcel.writeValue(audit)
        parcel.writeString(author)
        parcel.writeValue(canEdit)
        parcel.writeValue(chapterId)
        parcel.writeString(chapterName)
        parcel.writeValue(collect)
        parcel.writeValue(courseId)
        parcel.writeString(desc)
        parcel.writeString(descMd)
        parcel.writeString(envelopePic)
        parcel.writeValue(fresh)
        parcel.writeString(host)
        parcel.writeValue(id)
        parcel.writeValue(isAdminAdd)
        parcel.writeString(link)
        parcel.writeString(niceDate)
        parcel.writeString(niceShareDate)
        parcel.writeString(origin)
        parcel.writeString(prefix)
        parcel.writeString(projectLink)
        parcel.writeValue(publishTime)
        parcel.writeValue(realSuperChapterId)
        parcel.writeValue(selfVisible)
        parcel.writeValue(shareDate)
        parcel.writeString(shareUser)
        parcel.writeValue(superChapterId)
        parcel.writeString(superChapterName)
        parcel.writeString(title)
        parcel.writeValue(type)
        parcel.writeValue(userId)
        parcel.writeValue(visible)
        parcel.writeValue(zan)
    }

    override fun describeContents(): Int {
        return 0
    }

    companion object CREATOR : Parcelable.Creator<Article> {
        override fun createFromParcel(parcel: Parcel): Article {
            return Article(parcel)
        }

        override fun newArray(size: Int): Array<Article?> {
            return arrayOfNulls(size)
        }
    }
}